package com.ruoyi.web.controller.contract;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ContractProject;
import com.ruoyi.system.service.IContractProjectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/contract/project")
public class ContractProjectController extends BaseController
{
    @Autowired
    private IContractProjectService contractProjectService;

    /**
     * 查询【请填写功能名称】列表
     */
    //@PreAuthorize("@ss.hasPermi('system:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContractProject contractProject)
    {
        startPage();
        List<ContractProject> list = contractProjectService.selectContractProjectList(contractProject);
        return getDataTable(list);
    }

    /**
     * 数据统计列表信息
     * @param contractProject
     * @return
     */
    @GetMapping("/countList")
    public TableDataInfo countList(ContractProject contractProject)
    {
        startPage();
        List<ContractProject> list = contractProjectService.selectContractProjectcCountDataList(contractProject);
        return getDataTable(list);
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(ContractProject contractProject)
    {
        List<ContractProject> list = contractProjectService.selectContractProjectList(contractProject);
        return success(list);
    }


    /**
     * 导出【请填写功能名称】列表
     */
    //@PreAuthorize("@ss.hasPermi('system:project:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContractProject contractProject)
    {
        List<ContractProject> list = contractProjectService.selectContractProjectList(contractProject);
        ExcelUtil<ContractProject> util = new ExcelUtil<ContractProject>(ContractProject.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:project:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(contractProjectService.selectContractProjectById(id));
    }
    @GetMapping(value = "/getCountInfo/{id}")
    public AjaxResult getCountInfo(@PathVariable("id") Long id)
    {
        return success(contractProjectService.selectContractProjectCountById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:project:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContractProject contractProject)
    {
        return toAjax(contractProjectService.insertContractProject(contractProject));
    }

    /**
     * 修改【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:project:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractProject contractProject)
    {
        return toAjax(contractProjectService.updateContractProject(contractProject));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:project:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(contractProjectService.deleteContractProjectByIds(ids));
    }
}
